/**
 * Copyright 2014 Viettel Telecom. All rights reserved.
 * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.viettel.core.dao.cms;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.Type;
import org.springframework.beans.factory.annotation.Autowired;

import com.viettel.core.exceptions.DataAccessException;
import com.viettel.core.entities.cms.AnswersQuestion;
import com.viettel.core.repo.IRepository;

/**
 * Mo ta muc dich cua lop (interface)
 * 
 * @author: TOANTM1
 * @version:
 * @since: 27/02/2014 - 11:34:02
 */
public class AnswersQuestionDAOImpl implements AnswersQuestionDAO {
	private IRepository repo;

	public void setRepo(IRepository repo) {
		this.repo = repo;
	}

	/**
	 * @author TOANTM1 27/02/2014 - 11:34:02 For:
	 * @description:
	 */
	@Override
	public AnswersQuestion getAnswersQuestionById(Integer id)
			throws DataAccessException {
		return repo.getEntityById(AnswersQuestion.class, id);
	}

	/**
	 * @author TOANTM1 27/02/2014 - 11:34:02 For:
	 * @description:
	 */
	@Override
	public AnswersQuestion createAnswersQuestion(AnswersQuestion answersquestion)
			throws DataAccessException {
		if (answersquestion == null) {
			throw new IllegalArgumentException("answersquestion");
		}
		repo.create(answersquestion);
		return repo.getEntityById(AnswersQuestion.class,
				answersquestion.getId());
	}

	/**
	 * @author TOANTM1 27/02/2014 - 11:34:02 For:
	 * @description:
	 */
	@Override
	public void updateAnswersQuestion(AnswersQuestion answersquestion)
			throws DataAccessException {
		if (answersquestion == null) {
			throw new IllegalArgumentException("answersquestion");
		}
		repo.update(answersquestion);
	}

	/**
	 * @author TOANTM1 27/02/2014 - 11:34:02 For:
	 * @description:
	 */
	@Override
	public void deleteAnswersQuestion(AnswersQuestion answersquestion)
			throws DataAccessException {
		if (answersquestion == null) {
			throw new IllegalArgumentException("answersquestion");
		}
		repo.delete(answersquestion);
	}
}
